<?php

require_once ROOT_DIR.'models/User.php';
require_once ROOT_DIR.'views/UserJSON.php';

/**
 * Tries to fetch the user wit hthe given id from the database and echos its JSON view.
 * @param int $id
 */
function getUser($id){
	$user = User::getUser($id);
	if(is_null($user)){
		$res = new ResultJSON(true, session_id(), ERROR_USER_DOES_NOT_EXIST);
		echo $res->renderView();
	} else {
		echo UserJSON::getView($user);
	}
}

?>